// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env: cloud.DYNAMIC_CURRENT_ENV
}) // 使用当前云环境

const db = cloud.database()

// 云函数入口函数
exports.main = async (event, context) => {
    try {
        // 请求参数
        let {
            conditions,
            auditStatus
        } = event.data

        const res = db.collection('msgList').where(conditions).update({
            data: {
                auditStatus
            }
        })

        if (res.errMsg = "document.update:ok") {
            return {
                code: 200,
                msg: "审核成功",
            }
        } else {
            return {
                code: 401,
                data,
                msg: "审核失败",
            }
        }
    } catch {
        return {
            code: 500,
            message: err.message
        }
    }
}